package com.yonyou.cyxdms.sysAuth.service.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yonyou.cyx.framework.bean.dto.base.BaseDTO;
import com.yonyou.cyx.function.utils.bean.BeanMapperUtil;
import com.yonyou.cyxdms.framework.bean.entity.base.DMSBasePO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * <p>
 * 菜单权限表
 * </p>
 *
 * @author quankk
 * @since 2019-07-05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("tm_permission_menu")
public class PermissionMenuPO extends DMSBasePO<PermissionMenuPO> {

    private static final long serialVersionUID = 1L;

    /**
     * 权限菜单id
     */
    @TableId(value = "PERMISSION_MENU_ID", type = IdType.AUTO)
    private Long permissionMenuId;

    /**
     * 权限类型(用户,角色,职位,模板角色,模板职位)
     */
    @TableField("PERMISSION_TYPE")
    private Integer permissionType;

    /**
     * 权限类型对应的id
     */
    @TableField("PERMISSION_ID")
    private Integer permissionId;

    /**
     * 菜单ID
     */
    @TableField("MENU_ID")
    private Long menuId;

    /**
     * 是否柔性,如果是模板角色，模板职位设置的，不可修改，此值为0
     */
    @TableField("IS_FLEXIBLE")
    private Integer isFlexible;

    /**
     * 默认权限
     */
    @TableField("IS_EMPOWERED")
    private Integer isEmpowered;

    @TableField("APP_ID")
    private String appId;

    @Override
    protected Serializable pkVal() {
        return this.permissionMenuId;
    }

    /**
     * 将PO 信息转化为DTO
     *
     * @param dto 需要进行转换的dto
     * @author quankk
     * @since 2018/7/22 0022
     */
    protected <T extends BaseDTO> void transDtoToPo(T dto) {
        BeanMapperUtil.copyProperties(this, dto, "permissionMenuId");
    }

}
